package cn.ecut.Servlet;

import cn.ecut.Dao.cusshow;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

public class cusselfServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   String sname=request.getParameter("selfname");
   ch c=new ch();
        try {
            String []s1=c.cusshowinfo(sname);
            if(s1!=null){
                for (int i = 0; i < 5; i++) {
                    request.setAttribute("sfname",s1[0]);
                    request.setAttribute("sftel",s1[1]);
                    request.setAttribute("sfage",s1[2]);
                    request.setAttribute("sfmail",s1[3]);
                    request.setAttribute("sfgender",s1[4]);
                    System.out.println(s1[i]);
                    request.getRequestDispatcher("customer.jsp").forward(request,response);
                }
            }
            else{request.getRequestDispatcher("fail.jsp").forward(request,response);}
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public class ch extends cusshow {
        @Override
        public String[] cusshowinfo(String name) throws SQLException, ClassNotFoundException {
            return super.cusshowinfo(name);
        }
    }
}
